package com.dou.you.che.web.conf.mvc;

import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.Properties;

/**
 * MVC 相关配置
 * @Author 黄国刚【1058118328@qq.com】
 */
@Component
public class WebMvcAppConfig {

    /**
     * 验证码生成器配置
     * @return
     */
    @Bean(name = "producer")
    public DefaultKaptcha getProducer(){
        DefaultKaptcha kaptcha = new DefaultKaptcha();
        Properties properties = new Properties();
        properties.put("kaptcha.border","no");
        properties.put("kaptcha.textproducer.font.color","black");
        properties.put("kaptcha.textproducer.char.space","6");
        properties.put("kaptcha.textproducer.char.length","4");
        Config config = new Config(properties);
        kaptcha.setConfig(config);
        return kaptcha;
    }
}
